(function ($) {
	var timer;
	var queDict;
	var currPage=0;//当前是第几题
	var currSlideIndex = 0;
	var pageCount = 0;
	var pageType = '';
	var fromPage = ''
	var nurseid = '',rw=''
	var quesType={'S':'单选题','M':'多选题','B':'填空题','A':'问答题'}
	$.init();
	$.plusReady(function () {
	    baseSetup();
	})
	function sliderSlidAction(){
		var index = event.detail.slideNumber;
		var newPage = ''
		if (index > currSlideIndex) {
			newPage = currPage + 1
		}else{
			newPage = currPage - 1
		}
		
		var pageIndex = currPage - 1
		var item = document.getElementById(pageIndex)
		if (item.querySelector('.analysisMode')) {
			if ($('#chapterUL .dhc-active')[0]) {
				$('#chapterUL .dhc-active')[0].classList.remove('dhc-active')
			}
			$('#item-'+(newPage-1))[0].classList.add('dhc-active')
			updateSliderUI(newPage-1)
			return
		}
		var data = queDict[pageIndex]
		var type = data['SubMode']
		var optionsArea = item.querySelector('.optionsArea')
		var opDoms = optionsArea.querySelectorAll('.option.dhc-active')
		if (type == 'S' && opDoms.length !=0) {
			radioOptionTapped(opDoms[0],newPage)
			return
		}
		if (type == 'M' && opDoms.length !=0) {
			checkBoxSureTapped($('#sure-'+pageIndex)[0],newPage)
			return
		}
		if (type == 'B') {
			var blankDoms = optionsArea.querySelectorAll('.option input')
			var isAnsed = false
			for (var i = 0; i < blankDoms.length;i++) {
				if (blankDoms[i].value != '') {
					isAnsed = true
				}
			}
			if (isAnsed) {
				blankSureTapped($('#sure-'+pageIndex)[0],newPage)
				return
			}
		}
		if ($('#chapterUL .dhc-active')[0]) {
			$('#chapterUL .dhc-active')[0].classList.remove('dhc-active')
		}
		$('#item-'+(newPage-1))[0].classList.add('dhc-active')
		updateSliderUI(newPage-1)
	}
	
	//保存答案
	function saveOneChapterAnswer(index,type,nurseAns,dom,newPage){
		var dataDict = queDict[index]
		var time = timeToSecond(mui('#plusTime')[0].innerText)
		
		var parr = 'rw|'+dataDict['rw']+'^subRw|'+dataDict['SubRw']+'^Result|'+nurseAns+'^UsedTime|'+time+'^UserDR|'+nurseid+'^AnswerTimes|'+dataDict['AnswerTimes'];
		var pdict = {'parr':parr}
		var paramDict = {'method':'web.INMTeaComm:SaveLearnTheoryTest','params':JSON.stringify(pdict),'type':'Method'}
		$.DHCWebService(paramDict, function(result) {
			//console.log(JSON.stringify(result))
			var arr = result.msg.split('^')
			if (arr[0] == '0') {
				mui.toast(arr[1])
				if (type != 'S') {
					dom.style.display = 'block'
				}
				if (newPage) {
					$('#slider')[0].removeEventListener('slide',sliderSlidAction);
					mui('#slider').slider().gotoItem(currSlideIndex,0);
					$('#slider')[0].addEventListener('slide',sliderSlidAction);
				}
				return
			}
			queDict[index]['Result'] = nurseAns;
			switch (type) {
				case 'S':
					updateRadioUI(index,dom)
					break;
				case 'M':
					updateCheckBoxUI(index,dom)
					break;
				case 'B':
					updateBlankUI(index,dom)
					break;
			}
			var errorDom = $('#'+index)[0].querySelector('.nur-error')
			if (errorDom) {
				$('#item-'+index)[0].classList.add('error')
			}else{
				$('#item-'+index)[0].classList.add('success')
			}
			if (newPage) {
				updateSliderUI(newPage-1)
				if ($('#chapterUL .dhc-active')[0]) {
					$('#chapterUL .dhc-active')[0].classList.remove('dhc-active')
				}
				$('#item-'+(newPage-1))[0].classList.add('dhc-active')
			}
		}, function(errorStr) {
			mui.toast('请重试')
			if (type != 'S') {
				dom.style.display = 'block'
			}
			if (newPage) {
				$('#slider')[0].removeEventListener('slide',sliderSlidAction);
				mui('#slider').slider().gotoItem(currSlideIndex,0);
				$('#slider')[0].addEventListener('slide',sliderSlidAction);
			}
		});
	}
	// 题型--1单选,2多选,3填空,4问答
	function getExamineData(){
		var pdict = {'userId':nurseid,'rw':rw}
		//console.log(JSON.stringify(pdict))
		var paramDict = {'method':'web.INMTeaComm:FindAllProblem','params':JSON.stringify(pdict),'type':'RecQuery'}
		$.DHCWebService(paramDict, function(result) {
			//console.log(JSON.stringify(result))
			if (result.msgcode != '1') {
				mui.toast('失败')
				return
			}
			queDict = result['data']
			//console.log(queDict.length)
			updateExamUI()
		}, function(errorStr) {
		 	
		});
	}
	
	function updateExamUI(){
		$('#plusTime')[0].innerHTML = "00:00:00"
		var timeBtn =  $('#plusTime')[0];
		timer = setInterval(function() {
			timeBtn.innerText = hourMinuteSecondPlus(timeBtn.innerText);
		}, 1000);
		pageCount = queDict.length
		var num = 3
		if (pageCount < num) {
			num = pageCount
		}
		for(var i = 0; i < num;i++){
			updateOneQuesUI(i)
		}
		if ($('#0')[0]) {
			$('#0')[0].classList.add('mui-active')
		}
		$('#item-0')[0].classList.add('dhc-active')
		mui('#slider').slider().refresh();
		currSlideIndex = 0;
		currPage = 1;
		$('#currPage')[0].innerHTML = currPage;
		$('#pageCount')[0].innerHTML = pageCount;
	}
	
	function updateOneQuesUI(index,prePageDom){
		var sliderItem = $('#'+index)[0]
		if (!sliderItem) {
			sliderItem = document.createElement('div')
			sliderItem.setAttribute('class','mui-slider-item')
			sliderItem.id = index
			sliderItem.innerHTML = '<div class="mui-scroll-wrapper"><div class="mui-scroll"></div></div>'
			if (prePageDom) {
				$('#loop')[0].insertBefore(sliderItem,prePageDom);
			}else{
				$('#loop')[0].appendChild(sliderItem)
			}
		}
		var oneDict = queDict[index]
		var type = oneDict['SubMode']; //S单选 M多选 B填空 A问答
		var title = oneDict['SubDesc'];
		var sub = oneDict['SubSource'];
		if (type == 'B') {
			var arr = title.split('﹏﹏')
			title = ''
			for (var i= 0; i < arr.length;i++) {
				title += arr[i]
				if (i != arr.length - 1) {
					title += '<div class="blank">（'+(i+1)+'）</div>'
				}
			}
		}
		var html = '<div class="examTitle">'+(index+1)+'、<span class="examType">【'+quesType[type]+'】</span>'+title
		if(sub != ''){
			html += '<span class="subText">（'+sub+'）</span>'
		}
		html +='</div>'
		
		var muiScroll = sliderItem.querySelector('.mui-scroll')
		muiScroll.innerHTML = html
		switch (type) {
			case 'S':
				createRadioUI(oneDict,muiScroll,index);
				break;
			case 'M':
				createCheckboxUI(oneDict,muiScroll,index);
				break;
			case 'B':
				createMultiBlankUI(oneDict,muiScroll,index);
				break;
		}
	}
	
	// 单选
	function createRadioUI(oneDict,scrollDom,index){
		scrollDom.classList.remove('analysisMode')
		var option = oneDict['SubOption'].split('」')
		var optionsArea = document.createElement('div');
		optionsArea.id = 'ques-'+index
		optionsArea.classList.add('optionsArea');
		scrollDom.appendChild(optionsArea);
		
		var html = ''
		var nurAns = oneDict['Result'] 
		for(var i= 0; i < option.length;i++){
			var op = option[i];
			var activeClass=''
			if(nurAns!="" && i == nurAns){
				activeClass='dhc-active'
			}
			var str = String.fromCharCode(64 + parseInt(i+1));
			html += '<div class="option '+activeClass+'">'+
				'<div class="opName nurfont" data-op="'+i+'">'+str+'</div>'+
				'<div class="opTitle">'+op+'</div></div>'
		}
		optionsArea.innerHTML = html;
		if (oneDict['Result']=="") {
			var options = optionsArea.querySelectorAll('.option');
			for (var i = 0; i < options.length;i++) {
				options[i].addEventListener('tap',function(){
					radioOptionTapped(this)
				});
			}
			return
		}
		//解析部分
		radioOptionAddAnaly(optionsArea,scrollDom,index);
	}
	function radioOptionTapped(opDom,newPage){
		var parentNode = opDom.parentNode;
		var index = parseInt(parentNode.id.split('-')[1])
		var nurseAns = opDom.querySelector('.opName').getAttribute('data-op');
		saveOneChapterAnswer(index,'S',nurseAns,opDom,newPage)
	}
	
	function radioOptionAddAnaly(optionsArea,scrollDom,index){
		var oneDict = queDict[index]
		var SubAnswer = oneDict['SubAnswer']
		var error = optionsArea.querySelector('.dhc-active .opName');
		var userAns = error.innerText
		if (error.getAttribute('data-op') != SubAnswer) {
			error.innerHTML = ''
			error.classList.add('nur-error')
		}
		
		var correct = optionsArea.querySelector('.opName[data-op="'+SubAnswer+'"]');
		var correctAns = correct.innerText
		correct.innerHTML = ''
		correct.classList.add('nur-correct')
		
		scrollDom.classList.add('analysisMode')
		var analysisArea = document.createElement('div');
		analysisArea.classList.add('analysisArea');
		scrollDom.appendChild(analysisArea);
		var analysisText = oneDict['SubAnalysis'];
		var errorPercent=oneDict['errorRate']
		if (errorPercent == undefined) {
			errorPercent = ''
		}else{
			errorPercent = '，错误率'+errorPercent+'%'
		}
		html = '<div class="ansCompare">正确答案：<span class="correctAns">'+correctAns+'</span>&nbsp;&nbsp;'+
				'您的答案：<span class="yourAns">'+userAns+'</span></div>'+
			'<div class="seperateBar"></div>'+
			'<div class="analysisText">解析：<br/>'+analysisText+'</div>'+
			'<div class="seperateLine"></div><div class="errorRate">本系统作答 '+oneDict['AnswerTimes']+' 次'+errorPercent+'</div>'
		analysisArea.innerHTML = html
	}
	
	function updateRadioUI(index,opDom){
		var parentNode = opDom.parentNode
		var oldActive = parentNode.querySelector('.dhc-active');
		if (oldActive) {
			oldActive.classList.remove('dhc-active');
		}
		opDom.classList.add('dhc-active');
		
		var optionsArea = opDom.parentNode
		var scrollDom = optionsArea.parentNode
		var options = optionsArea.querySelectorAll('.option');
		mui.each(options,function(index,item){
			item.removeEventListener('tap',radioOptionTapped)
		})
		if (scrollDom.getAttribute('class').indexOf('analysisMode')!= -1) {
			return;
		}
		radioOptionAddAnaly(optionsArea,scrollDom,index);
	}
	
	// 多选
	function createCheckboxUI(oneDict,scrollDom,index){
		scrollDom.classList.remove('analysisMode')
		var option = oneDict['SubOption'].split('」')
		var optionsArea = document.createElement('div');
		optionsArea.id = 'ques-'+index
		optionsArea.classList.add('optionsArea');
		scrollDom.appendChild(optionsArea);
		
		var html = ''
		var nurAns = oneDict['Result'] 
		for(var i= 0; i < option.length;i++){
			var op = option[i];
			var activeClass=''
			if(nurAns!="" && ('」'+nurAns+'」').indexOf('」'+i+'」') != -1){
				activeClass='dhc-active'
			}
			var str = String.fromCharCode(64 + parseInt(i+1));
			html += '<div class="option '+activeClass+'">'+
				'<div class="opName nurfont" data-op="'+i+'">'+str+'</div>'+
				'<div class="opTitle">'+op+'</div></div>'
		}
		optionsArea.innerHTML = html;
		//确认答案
		var sureAnsBtn = document.createElement('div');
		sureAnsBtn.id = 'sure-'+index
		sureAnsBtn.classList.add('sureAnsBtn');
		sureAnsBtn.innerText = '确认答案'
		sureAnsBtn.addEventListener('tap',function(){
			checkBoxSureTapped(this)
		})
		scrollDom.appendChild(sureAnsBtn);
		// 点击方法
		if (nurAns=="") {
			var options = optionsArea.querySelectorAll('.option');
			for (var i = 0; i < options.length;i++) {
				options[i].addEventListener('tap',checkboxOptionTapped);
			}
			return
		}
		//解析部分
		checkboxOptionAddAnaly(optionsArea,scrollDom,index);
	}
	
	function checkBoxSureTapped(checkBtn,newPage){
		checkBtn.style.display = 'none'
		var chekIndex = checkBtn.id.split('-')[1]
		var optionsArea = checkBtn.parentNode.querySelector('.optionsArea')
		var activeDoms = optionsArea.querySelectorAll('.option.dhc-active')
		var nurAns = ''
		for (var i = 0; i < activeDoms.length;i++) {
			nurAns += i
			if (i != activeDoms.length - 1) {
				nurAns += '」'
			}
		}
		if (activeDoms.length == 0) {
			mui.toast('请选择您的答案')
			return
		}
		saveOneChapterAnswer(chekIndex,"M",nurAns,checkBtn,newPage)
	}
	
	function checkboxOptionAddAnaly(optionsArea,scrollDom,index){
		var oneDict = queDict[index]
		var SubAnswerStr = '」'+oneDict['SubAnswer']+'」'
		var errorDoms = optionsArea.querySelectorAll('.dhc-active .opName');
		var userAns = ''
		for (var i = 0; i < errorDoms.length;i++) {
			var errDom = errorDoms[i]
			userAns += errDom.innerHTML
			if (SubAnswerStr.indexOf('」'+errDom.getAttribute('data-op')+'」') != -1) {
				continue
			}
			errDom.innerHTML = ''
			errDom.classList.add('nur-error')
		}
		var SubAnswer = oneDict['SubAnswer'].split(',') //」
		var correctAns = ''
		for (var i = 0; i < SubAnswer.length;i++) {
			var correct = optionsArea.querySelector('.opName[data-op="'+SubAnswer[i]+'"]');
			if (!correct) {
				continue
			}
			correctAns += correct.innerHTML
			correct.innerHTML = ''
			correct.classList.add('nur-correct')
		}
		scrollDom.classList.add('analysisMode')
		var analysisArea = document.createElement('div');
		analysisArea.classList.add('analysisArea');
		scrollDom.appendChild(analysisArea);
		var analysisText = oneDict['SubAnalysis'];
		var errorPercent=oneDict['errorRate']
		if (errorPercent == undefined) {
			errorPercent = ''
		}else{
			errorPercent = '，错误率'+errorPercent+'%'
		}
		html = '<div class="ansCompare">正确答案：<span class="correctAns">'+correctAns+'</span>&nbsp;&nbsp;'+
				'您的答案：<span class="yourAns">'+userAns+'</span></div>'+
			'<div class="seperateBar"></div>'+
			'<div class="analysisText">解析：<br/>'+analysisText+'</div>'+
			'<div class="seperateLine"></div><div class="errorRate">本系统作答 '+oneDict['AnswerTimes']+' 次'+errorPercent+'</div>'
		analysisArea.innerHTML = html
	}
	function checkboxOptionTapped(){
		if (this.getAttribute('class').indexOf('dhc-active') != -1) {
			this.classList.remove('dhc-active');
		}else{
			this.classList.add('dhc-active');
		}
	}
	function updateCheckBoxUI(index,btnDom){
		var scrollDom = btnDom.parentNode
		var options = scrollDom.querySelectorAll('.optionsArea .option')
		mui.each(options,function(index,item){
			item.removeEventListener('tap',checkboxOptionTapped)
		})
		scrollDom.removeChild(btnDom)
		if (scrollDom.getAttribute('class').indexOf('analysisMode')!= -1) {
			return;
		}
		checkboxOptionAddAnaly(scrollDom.querySelector('.optionsArea'),scrollDom,index);
	}
	
	// 填空
	function createMultiBlankUI(oneDict,scrollDom,index){
		scrollDom.classList.remove('analysisMode')
		var optionsArea = document.createElement('div');
		optionsArea.id = 'ques-'+index
		optionsArea.classList.add('optionsArea');
		scrollDom.appendChild(optionsArea);
		
		var html = ''
		var Result = oneDict['Result'].split('」')
		var isAnsed = false //已答题
		for(var i= 0; i< Result.length;i++){
			html += '<div class="option"><div class="fillName">（'+(i+1)+'）</div><input type="text" value="'+Result[i]+'" /></div>'
			if (Result[i]!= '') {
				isAnsed = true
			}
		}
		optionsArea.innerHTML = html;
		//确认答案
		var sureAnsBtn = document.createElement('div');
		sureAnsBtn.id = 'sure-'+index
		sureAnsBtn.classList.add('sureAnsBtn');
		sureAnsBtn.innerText = '确认答案'
		sureAnsBtn.addEventListener('tap',function(){
			blankSureTapped(this)
		})
		scrollDom.appendChild(sureAnsBtn);
		if (isAnsed) {
			blankAddAnaly(optionsArea,scrollDom,index)
		}
	}
	
	function blankSureTapped(sureBtn,newPage){
		sureBtn.style.display = 'none'
		var blankIndex = sureBtn.id.split('-')[1]
		var optionsArea = sureBtn.parentNode.querySelector('.optionsArea')
		var blankDoms = optionsArea.querySelectorAll('.option input')
		var nurAns = ''
		var isAnsed = false
		for (var i = 0; i < blankDoms.length;i++) {
			nurAns += blankDoms[i].value
			if (blankDoms[i].value != '') {
				isAnsed = true
			}
			if (i != blankDoms.length - 1) {
				nurAns += '」'
			}
		}
		if (!isAnsed) {
			sureBtn.style.display = 'block'
			mui.toast('请输入您的答案')
			return
		}
		saveOneChapterAnswer(blankIndex,"B",nurAns,sureBtn,newPage)
	}
	
	function blankAddAnaly(optionsArea,scrollDom,index){
		var oneDict = queDict[index]
		var nurAns = oneDict['Result'].split('」')
		var standAns = oneDict['SubAnswer'].split('」')
		optionsArea.style.display = 'none';
		scrollDom.classList.add('analysisMode')
		var analysisArea = document.createElement('div');
		analysisArea.classList.add('analysisArea');
		scrollDom.appendChild(analysisArea);
		//包含答案即可得分 SubAnsConFlag: "1" 区分大小写		SubAnsCaseFlag: "1"  不区分答案先后顺序 SubAnsOrderFlag: "1"
		var conFlag = oneDict['SubAnsConFlag']
		var caseFlag = oneDict['SubAnsCaseFlag']
		var orderFlag = oneDict['SubAnsOrderFlag']
		html = ''
		var inputs = optionsArea.querySelectorAll('input')
		var title = oneDict['SubDesc'];
		var arr = title.split('﹏﹏')
		var ansText = ''
		for (var i= 0; i< inputs.length;i++) {
			ansText += arr[i]
			if (i != arr.length - 1) {
				ansText += '<div class="blank">'+standAns[i]+'</div>'
			}
			var value = inputs[i].value
			html += '<div class="option"><div class="fillName">（'+(i+1)+'）</div>'+
				'<div class="fillText">'+value+'</div>';
			if (compareBlankValue(value,standAns,conFlag,caseFlag,orderFlag,i)) {
				html += '<div class="nurfont nur-correct"></div></div>'
			}else{
				html += '<div class="nurfont nur-error"></div></div>'
			}
		}
		var analysisText = oneDict['SubAnalysis']
		var errorPercent=oneDict['errorRate']
		if (errorPercent == undefined) {
			errorPercent = ''
		}else{
			errorPercent = '，错误率'+errorPercent+'%'
		}
		html += '<div class="correctFillText">正确答案：<br/>'+ansText+'</div>'+
			'<div class="seperateBar"></div>'+
			'<div class="analysisText">解析：<br/>'+analysisText+'</div>'+
			'<div class="seperateLine"></div><div class="errorRate">本系统作答 '+oneDict['AnswerTimes']+' 次'+errorPercent+'</div>'
		analysisArea.innerHTML = html
	}
	
	function compareBlankValue(value,nurAnsArr,conFlag,caseFlag,orderFlag,index){
		//包含答案即可得分 SubAnsConFlag: "1" 区分大小写		SubAnsCaseFlag: "1"  不区分答案先后顺序 SubAnsOrderFlag: "1"
		if (caseFlag != '1') {
			value = value.toUpperCase()
			var str = nurAnsArr.join('」').toUpperCase()
			nurAnsArr = str.split('」')
		}
		if (orderFlag != '1') { //区分顺序
			var ans = nurAnsArr[index]
			if (conFlag != '1') { //完全一致
				if (value == ans) {
					return 1
				}
			}else{
				if (value.indexOf(ans) != -1) {
					return 1
				}
			}
		}else{
			var str = nurAnsArr.join('」')
			if (conFlag != '1') { //完全一致
				if (('」'+str+'」').indexOf('」'+value+'」') != -1) {
					return 1
				}
			}else{
				if (str.indexOf(value) != -1) {
					return 1
				}
			}
		}
		return 0
	}
	
	function updateBlankUI(index,btnDom){
		var scrollDom = btnDom.parentNode
		scrollDom.removeChild(btnDom)
		if (scrollDom.getAttribute('class').indexOf('analysisMode')!= -1) {
			return;
		}
		var optionsArea = scrollDom.querySelector('.optionsArea');
		blankAddAnaly(optionsArea,scrollDom,index);
		
	}
	function baseSetup(){
		$('.mui-scroll-wrapper').scroll({
			bounce: true,
			indicators: false, //是否显示滚动条
		});
		var self = plus.webview.currentWebview()
		var selfData = self.sourceData;
		pageType = self.pageType;
		fromPage = self.fromPage;
		nurseid = selfData['nurseid']
		rw = selfData['rw'];
		if (fromPage == 'examChapter') {
			$('.mui-title')[0].innerText = '章节练习'
		}else{
			$('.mui-title')[0].innerText = '错题本'
		}
		$('.btnArea')[0].classList.add('chapterMode')
		updateChapterWrapperUI(selfData['firstChapter'])
		$('.mui-content .btnArea .chapterTitle')[0].addEventListener('tap',function(){
			if ($('.btnArea')[0].getAttribute('class').indexOf('dhc-active') != -1) {
				$('.btnArea')[0].classList.remove('dhc-active')
				$('#dhcBackdrop')[0].classList.remove('dhc-active')
			}else{
				$('.btnArea')[0].classList.add('dhc-active')
				$('#dhcBackdrop')[0].classList.add('dhc-active')
			}
		})
		
		// 监听滚动
		$('#slider')[0].addEventListener('slide',sliderSlidAction);
		getExamineData()
		mui.back = function(){
			var fromWebview = plus.webview.getWebviewById(fromPage)
			fromWebview.evalJS("refreshPageData()")
			plus.webview.currentWebview().close();
		}
	}
	function updateSliderUI(index){
		var loop = $('#loop')[0]
		var currPageDom = $('#'+(currPage-1))[0]
		var nextPageDom = currPageDom.nextElementSibling
		var prePageDom = currPageDom.previousElementSibling
		currPageDom.classList.remove('mui-active')
		if (currPage < index + 1) { //下一题
			if (currPage == 1 || currPage == pageCount - 1) { //第一页滑到第二页  滑到最后一页
				if (currPage == pageCount - 1) {
					currSlideIndex = 2;
				}else{
					currSlideIndex = 1;
				}
				currPage = index + 1;
				$('#currPage')[0].innerHTML = currPage;
				nextPageDom.classList.add('mui-active')
				return
			}
			loop.removeChild(prePageDom)
			updateOneQuesUI(index+1)
		}else { //上一题
			if(index == 0){
				currSlideIndex = 0;
				currPage = index + 1;
				$('#currPage')[0].innerHTML = currPage;
				prePageDom.classList.add('mui-active')
				return
			}
			if (currPage == pageCount) { //滑到倒数第二页
				currSlideIndex = 1;
				currPage = index + 1;
				$('#currPage')[0].innerHTML = currPage;
				prePageDom.classList.add('mui-active')
				return
			}
			prePageDom.classList.add('mui-active')
			loop.removeChild(nextPageDom)
			updateOneQuesUI(index-1,prePageDom)
		}
		currSlideIndex = 1;
		currPage = index + 1;
		$('#currPage')[0].innerHTML = currPage;
		mui('#slider').slider().refresh();
		$('#slider')[0].removeEventListener('slide',sliderSlidAction);
		mui('#slider').slider().gotoItem(currSlideIndex,0);
		$('#slider')[0].addEventListener('slide',sliderSlidAction);
	}
	function updateChapterWrapperUI(dataDict){
		$('#chapterTitle')[0].innerText = dataDict['TheoryDesc']
		var chapterUL = $('#chapterUL')[0]
		var secs = dataDict['children']
		if (!secs) { //没有二级节点
			var html = '<li class="mui-table-view-cell">'
			var dict = getChapterHtml(dataDict,0)
			html += dict['html']
			html += '</li>'
			chapterUL.innerHTML = html
			return
		}
		var html = ''
		var preCount = 0
		for (var i = 0; i < secs.length;i++) {
			var oneSec = secs[i]
			html += '<li class="mui-table-view-cell"><div class="chapterBg">'+oneSec['TheoryDesc']+'</div>'
			var thirds = oneSec['children']
			if (!thirds) { //没有三级节点
				var dict = getChapterHtml(oneSec,preCount)
				html += dict['html']
				preCount = dict['preCount']
				html += '</li>'
				continue
			}
			
			for (var j = 0;j < thirds.length;j++) {
				var oneThird = thirds[j]
				html += '<div class="chapterSub">'+oneThird['TheoryDesc']+'</div>'
				var dict = getChapterHtml(oneThird,preCount)
				html += dict['html']
				preCount = dict['preCount']
			}
			html += '</li>'
		}
		chapterUL.innerHTML = html
	}
	
	function getChapterHtml(dataDict,preCount){
		var AllNum = parseInt(dataDict['AllNum'])
		var AnswerNum = parseInt(dataDict['AnswerNum'])
		var count = AllNum - AnswerNum
		if (count == 0) {
			count = AllNum
		}
		var html = '<div class="chapterItemArea">'
		for (var i = 0; i < count;i++) {
			html += '<div class="chapterItem" id="item-'+(i + preCount)+'">'+(i + 1 + preCount)+'</div>'
		}
		html += '</div>'
		return {"html":html,'preCount':(preCount+count)}
	}
})(mui);

/*
包含答案即可得分 SubAnsConFlag: "1"
区分大小写		SubAnsCaseFlag: "1"
不区分答案先后顺序 SubAnsOrderFlag: "1"

*/